<include file="Public/header"/>
<form class="layui-form" action="" id="user">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户名：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[username]" lay-verify="required" autocomplete="off" class="layui-input" placeholder="用户名">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">姓名：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[realname]" lay-verify="required" autocomplete="off" class="layui-input" placeholder="姓名">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">登录密码：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[password]" autocomplete="off" value="" placeholder="修改登录密码" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">支付密码：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[paypassword]" lay-verify="" autocomplete="off" value="" placeholder="修改支付密码" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">性别：</label>
                <div class="layui-input-inline">
                    <select name="u[sex]" lay-search="">
                        <option <if condition="$u['sex'] eq 0">selected</if> value="0">女</option>
                        <option <if condition="$u['sex'] eq 1">selected</if> value="1">男</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">身份证号：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[sfznumber]" lay-verify="required" autocomplete="off" placeholder="身份证号" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">出生日期：</label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="u[birthday]" placeholder="出生日期" id="birthday">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">手机号码：</label>
                <div class="layui-input-inline">
                    <input class="layui-input" name="u[mobile]" placeholder="">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系QQ：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[qq]" autocomplete="off" placeholder="联系QQ" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">Email：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[email]" lay-verify="required" autocomplete="off" placeholder="Email" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">用户级别：</label>
                <div class="layui-input-inline">
                    <select name="u[groupid]" lay-verify="required" lay-search="">
                        <option value=""></option>
                        <foreach name="groupId" item="v" key="k">
                            <option <if condition="$u['groupid'] eq $k">selected</if>
                            value="<{$k}>"><{$v}></option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">联系地址：</label>
                <div class="layui-input-inline">
                    <input type="text" name="u[address]" lay-verify="required" autocomplete="off" placeholder="联系地址" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">所属代理商：</label>
                <div class="layui-input-inline">
                    <select name="u[parentid]" lay-verify="required" lay-search="">
                        <option value="1">无代理商</option>
                        <foreach name="group" item="v" key="k">
                            <option value="<{$v['id']}>"><{$v['realname']}></option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结算方式：</label>
                <div class="layui-input-inline">
                    <select name="u[withdrawtype]" lay-verify="required" lay-search="">
                        <option value=""></option>
                        <option value="1">仅子商户可提</option>
                        <option value="2">仅代理商户可提</option>
                        <option value="3">子商户、代理商户均可提</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"></label>
                <button  class="btn btn-primary" lay-submit="submit" lay-filter="save">提交保存</button>
            </div>
        </div>
    </form>
<include file="Public/footer"/>
<script>
    layui.use(['layer', 'form','laydate'], function(){
        var form = layui.form
            ,laydate = layui.laydate
            ,layer = layui.layer;

        //常规用法
        laydate.render({
            elem: '#birthday'
        });
        //监听提交
        form.on('submit(save)', function(data){
            $.ajax({
                url:"<{:U('User/saveUser')}>",
                type:"post",
                data:$('#user').serialize(),
                success:function(res){
                    if(res.status){
                        layer.alert("编辑成功", {icon: 6},function () {
                            parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.alert("操作失败:" + res.msg, {icon: 5},function (index) {
                            layer.close(index)
                        });
                    }
                }
            });
            return false;
        });
    });
</script>